import React, { Component } from 'react';

import Child from './Child';
import About from '../about/';

import { ResumeContenxt } from './_store';

class View extends Component {
    constructor(props){
        super(props);
        this.state = {
            base:{
                name:'',
                age:'',
                genders:'male'
            }
        }
    }
    _init(){
        this.setState({
            base:{
                name:'新名字',
                age:32,
                genders:'nv'
            }
        })
    }
    componentDidMount(){
        setTimeout(()=>{
            this._init()
        },2000)
    }
    contextFn(test){
        console.log(test)
    }
    left(){
        return(
            <div>test内容</div>
        )
    }
    com(){
        return <About/>
    }
    render(){
        return(
            <div>
                <h3>这是contextParent组件</h3>
                {this.left()}
                <ResumeContenxt.Provider value={{
                    base:this.state.base,  // 基础数据类型
                    callback:this.contextFn,  // 子组件回调 信息返回给父组件
                    left:this.left,   // 直接接受某些内容
                    com:this.com    // 可以直接接受某个组件
                }}>
                    <Child/>
                </ResumeContenxt.Provider>
            </div>
        )
    }
}









export default View;
